open Unix

open Common
open Io

type control_connect =
    { host : host_entry;   (* host of the ftp server *)
      socket_fd : file_descr; (* socket of the control connection  *)
    }

type auth_info =
    { mutable username : string;
      mutable password : string;
      mutable acctinfo : string;
    }

type x_feature =
    { mutable size : bool;
      mutable rest : bool;
      mutable mdtm : bool;
      mutable mlst : bool;
      mutable mlsd : bool;
    }

type ftp_session =
    { cc : control_connect;
      auth : auth_info;
      x_feats : x_feature;
      
      mutable passive : bool;
      mutable data_port : int;
      mutable workdir : string;
      mutable closed : bool;
      mutable charset : string;
    }

(******************************************************************************)

let default_connect =
  { host = gethostbyname (gethostname ());
    socket_fd = stdout;
  }

let anonymous_auth_info =
  { username = "anonymous";
    password = "xxx@xxx.xxx";
    acctinfo = "";
  }

let emp_x_features =
  { size = false;
    rest = false;
    mdtm = false;
    mlst = false;
    mlsd = false;    
  }

let default_ftp_session =
  { cc = default_connect;
    auth = anonymous_auth_info;
    x_feats = emp_x_features;
    passive = true;
    data_port = 0;
    workdir = "/";
    closed = true;
    charset = "C";
  }
